home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Tools 3
/
Amiga Tools 3.iso
/
programming
/
colpectius1
/
maze_generator.amos
/
maze_generator.amosSourceCode
Wrap
AMOS Source Code
|
1993-08-18
|
2KB
|
63 lines
' Maze Generator
' ~~~~~~~~~~~~~~
' by Ben Wyatt, bwyatt@paston.co.uk
' Creates a pretty crap maze, with always at least one way of getting
' from one point to another, usually two or more.
' Turbo/AMCAF users can replace the Point/Draw commands
Put Key "3" : Input "Scale (1-6) :";S
If S<1 Then S=1
If S>6 Then S=6
S=2^S
SC=1 : XS=S*SC : YS=S*SC
Global SC,XS,YS,XP,YP,XN
Dim DX(3),DY(3)
Global DX(),DY()
For N=0 To 3
Read DX(N),DY(N)
Next N
Data -1,0,1,0,0,-1,0,1
Screen Open 0,320,256,2,Lowres
Screen Display 0,128,37,320,256
Flash Off : Curs Off : Cls 0
Palette $0,$FFF
_MAZE[0,0]
Direct
Procedure _MAZE[X,Y]
XN=0
Box 0,0 To(320-XS)*SC,(256-YS)*SC
Repeat
Repeat
CN=0
Repeat
D=Rnd(3) : Inc CN
Until Point((X+DX(D))*XS,(Y+DY(D))*YS)=0 or CN=10
If CN<10
Draw X*XS,Y*YS To(X+DX(D))*XS,(Y+DY(D))*YS
Add X,DX(D) : Add Y,DY(D)
End If
Until Rnd(250)=1 or CN=10
_CHECK : X=XP : Y=YP
Until Param
End Proc
Procedure _CHECK
DN=True
For X=XN To 319*SC Step XS
For Y=0 To 255*SC Step YS
If Point(X-XS,Y)=0 or Point(X+XS,Y)=0 or Point(X,Y-YS)=0 or Point(X,Y+YS)=0
XN=X : CN=0
Repeat
XP=Rnd(320/XS) : YP=Rnd(256/YS) : Inc CN
Until Point(XP-XS,YP)=0 or Point(XP+XS,YP)=0 or Point(XP,YP-YS)=0 or Point(XP,YP+YS)=0 or CN=2
If CN=2 : XP=X/XS : YP=Y/YS : End If
DN=False : X=319*SC : Y=255*SC
End If
Next Y
Next X
End Proc[DN]